package com.xiaohu.controller;

import com.xiaohu.common.ResultEntity;
import com.xiaohu.entity.User;
import com.xiaohu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController//次注解等于Controller+Responsebody
@RequestMapping("/user")
public class UserController {
    @Autowired//Spring自动装配 为其自动创建对象
    private UserService userService;

    @RequestMapping("selectAll")
    public ResultEntity selectAll() {

        List<User> users = userService.selectAll();
        return new ResultEntity(ResultEntity.OK, ResultEntity.QUERY_OK, users.size(), users);
    }
}
